home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / Tools.vbs < prev    next >
Encoding:
Text File  |  2004-10-24  |  3.5 KB  |  138 lines

  1. 'FMA Script Framework Plugin
  2. 'Tools
  3. 'aka the first useful plugin for this framework ^^
  4.  
  5. 'Windows shutdown:
  6. 'RunDll32.EXE Shell32.Dll,SHExitWindowsEx n 
  7. '0 = Abmelden (== Neu anmelden) (8,16,32,64,128; -1) 
  8. '1 = Runterfahren und Ausschalten 
  9. '2 = Neu Booten 
  10. '4 = Alle aktiven Programme abwⁿrgen
  11.  
  12. 'TODO:
  13. '-Test logoff, shutdown, reboot
  14.  
  15. Class Tools
  16.     
  17.     Private List
  18.     Private m_Self
  19.     Private m_MenuReg
  20.     Private mainMenu
  21.     
  22.     'Some info about the plugin
  23.     Public Property Get SHOWABLE 'Do I have a menu?
  24.         SHOWABLE    = True
  25.     End Property
  26.     Public Property Get TITLE 'What's my name?
  27.         TITLE       = "General tools"
  28.     End Property
  29.     Public Property Get DESCRIPTION 'What's my purpose?
  30.         DESCRIPTION = "Miscellaneous stuff to interact wit the PC"
  31.     End Property
  32.     Public Property Get AUTHOR 'Who created me?
  33.         AUTHOR      = "dVrVm"
  34.     End Property
  35.     Public Property Get URL 'Were can I be found? Where can you get more information?
  36.         URL = "http://fma.xinium.com/"
  37.     End Property
  38.     
  39.     'Who am I?
  40.     Public Property Let Self (s)
  41.         m_Self = s
  42.         ' Some init stuff here:
  43.         Set List = New LinkedList
  44.         Dim bi
  45.         bi = List.BackInserter
  46.         bi.Item = Array( "Monitor off",    s & ".MonOff" )
  47.         bi.Item = Array( "Monitor on",     s & ".MonOn" )
  48.         bi.Item = Array( "Lock WS",        s & ".Lock" )
  49.         bi.Item = Array( "Log off",        s & ".LogOff" )
  50.         bi.Item = Array( "Hibernate",      s & ".Hibernate" )
  51.         bi.Item = Array( "Shutdown",       s & ".Shutdown" )
  52.         bi.Item = Array( "Reboot",         s & ".Reboot" )
  53.         bi.Item = Array( "Cancel Shutdown",s & ".CancelShutdown" )
  54.         bi.Item = Array( "Disconnect FMA", s & ".Disconnect" )
  55.         bi.Item = Array( "Disconnect Temporary", s & ".DisconnectTemp" )
  56.         bi.Item = Array( "Close FMA",      s & ".CloseFMA" )
  57.         If IsEmpty(Settings(Me, "FMATitle")) or Settings(Me, "FMATitle") = "" Then Settings(Me, "FMATitle") = "floAt's Mobile Agent"
  58.         Set mainMenu = New ManagedMenu
  59.         mainMenu.Title = TITLE
  60.         mainMenu.SetList List
  61.     End Property
  62.     Public Property Get Self
  63.         Self = m_Self
  64.     End Property
  65.     
  66.     Sub Show()
  67.         mainMenu.ShowMenu
  68.     End Sub
  69.     
  70.     ' Locks the workstation
  71.     Sub Lock
  72.         Shell.Run "Rundll32.exe user32.dll,LockWorkStation"
  73.         am.Update
  74.     End Sub
  75.     
  76.     ' Log off the current user
  77.     Sub LogOff
  78.         Shell.Run "LogOff"
  79.         am.Update
  80.         fma.Disconnect
  81.     End Sub
  82.     
  83.     ' Shuts down the PC
  84.     Sub Shutdown
  85.         'Shell.Run "RunDll32.EXE Shell32.Dll,SHExitWindowsEx 1"
  86.         Shell.Run "shutdown -f -s -t 30"
  87.         am.Title = "Shutdown.."
  88.         fma.Disconnect
  89.     End Sub
  90.     
  91.     ' Reboots the PC
  92.     Sub Reboot
  93.         'Shell.Run "RunDll32.EXE Shell32.Dll,SHExitWindowsEx 2"
  94.         Shell.Run "shutdown -f -r -t 30"
  95.         am.Title = "Reboot.."
  96.         fma.Disconnect
  97.     End Sub
  98.     
  99.     Sub CancelShutdown
  100.         Shell.Run "shutdown.exe -a"
  101.         am.Title = "Canceled"
  102.         am.Update
  103.     End Sub
  104.     
  105.     ' Hibernate
  106.     Sub Hibernate
  107.         Shell.Run "Rundll32.exe powrprof.dll,SetSuspendState"
  108.         fma.Disconnect
  109.     End Sub
  110.     
  111.     ' Disconnects the mobile phone from FMA
  112.     Sub Disconnect
  113.         fma.Disconnect
  114.     End Sub
  115.  
  116.     ' Disconnects temporary the mobile phone from FMA to allow disable BT connection and keep autoconnect alive
  117.     Sub DisconnectTemp
  118.         fma.DisconnectTemporary
  119.     End Sub
  120.  
  121.     ' Closes FMA
  122.     Sub CloseFMA
  123.         If Shell.AppActivate(Settings(Me, "FMATitle")) Then Shell.SendKeys "%{F4}"
  124.     End Sub
  125.     
  126.     ' Switches the monitor off
  127.     Sub MonOff
  128.         Shell.Exec ScriptFolder & "helper\moncloser 0"
  129.         am.Update
  130.     End Sub    
  131.     
  132.     ' Switches the monitor on
  133.     Sub MonOn
  134.         Shell.Exec ScriptFolder & "helper\moncloser 1"
  135.         am.Update
  136.     End Sub
  137.     
  138. End Class